<template>
  <component :is="current" :ref="current" v-model="ruleJson" :rule-type="ruleType" />
</template>
<script>
import R1 from './RdcRule1.vue'
import R2 from './RdcRule2.vue'
import R3 from './RdcRule3.vue'
import R4 from './RdcRule4.vue'
import R5 from './RdcRule5.vue'
import R6 from './RdcRule6.vue'
import R7 from './RdcRule7.vue'
import R9 from './RdcRule9.vue'
const ruleMap = { 1: 'R1', 2: 'R2', 3: 'R3', 4: 'R4', 5: 'R5', 6: 'R6', 7: 'R7', 8: 'R7', 9: 'R9', 10: 'R7' }
export default {
  name: 'RdcRuleType',
  components: { R1, R2, R3, R4, R5, R6, R7, R9 },
  props: {
    value: { type: String, default: '' },
    ruleType: { type: [String, Number], default: '' }
  },
  computed: {
    ruleJson: {
      get() {
        return this.value
      },
      set(val) {
        this.$emit('input', val)
      }
    },
    current() {
      return ruleMap[this.ruleType] || ''
    }
  },
  methods: {
    async validate() {
      return this.$refs[this.current]?.validate()
    }
  }
}
</script>
